package com.androidx.p013lv.mine.model;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.mine.bean.EditInfoReq;
import com.androidx.p013lv.mine.bean.UploadImgBean;
import com.google.gson.Gson;
import com.lzy.okgo.model.Progress;
import java.io.File;

/* renamed from: com.androidx.lv.mine.model.EditUserModel */
public class EditUserModel extends ViewModel {
    private MutableLiveData<BaseRes<UserInfo>> modifyData;
    private MutableLiveData<BaseRes<UploadImgBean>> uploadImgData;

    public MutableLiveData<BaseRes<UserInfo>> dataModify() {
        if (this.modifyData == null) {
            this.modifyData = new MutableLiveData<>();
        }
        return this.modifyData;
    }

    public MutableLiveData<BaseRes<UploadImgBean>> dataImg() {
        if (this.uploadImgData == null) {
            this.uploadImgData = new MutableLiveData<>();
        }
        return this.uploadImgData;
    }

    public void updateAvatar(File file) {
        HttpUtils.getInsatance().post_form(UrlManager.getInsatance().uploadAvatar(), file, new HttpCallback<BaseRes<UploadImgBean>>("uploadImg") {
            /* class com.androidx.p013lv.mine.model.EditUserModel.C13441 */

            public void onLvSuccess(BaseRes<UploadImgBean> baseRes) {
                EditUserModel.this.uploadImgData.setValue(baseRes);
            }

            @Override // com.lzy.okgo.callback.AbsCallback, com.lzy.okgo.callback.Callback
            public void uploadProgress(Progress progress) {
                super.uploadProgress(progress);
                BaseRes baseRes = new BaseRes(1000001, "");
                UploadImgBean uploadImgBean = new UploadImgBean();
                uploadImgBean.setProgressNum((float) (((int) progress.fraction) * 100));
                baseRes.setData(uploadImgBean);
                EditUserModel.this.uploadImgData.setValue(baseRes);
            }
        });
    }

    public void modifyUserInfo(EditInfoReq editInfoReq) {
        HttpUtils.getInsatance().post(UrlManager.getInsatance().modifyInfo(), new Gson().toJson(editInfoReq), new HttpCallback<BaseRes<UserInfo>>("modifyInfo") {
            /* class com.androidx.p013lv.mine.model.EditUserModel.C13452 */

            public void onLvSuccess(BaseRes<UserInfo> baseRes) {
                EditUserModel.this.modifyData.setValue(baseRes);
            }
        });
    }

    public void cancelHttp() {
        HttpUtils.getInsatance().cancelTag("uploadImg");
        HttpUtils.getInsatance().cancelTag("logo");
        HttpUtils.getInsatance().cancelTag("modifyInfo");
    }
}
